<html lang="en"><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        .pager {
            max-width: 800px;
            text-align: center;
            margin-bottom: 30px;
            display: inline-block;
        }

        .pager a,
        .pager span {
            width: 45px;
            height: 40px;
            flex-shrink: 0;
            border: 1px solid #333;
            cursor: pointer;
            color: #8a8a8a;
            -moz-user-select: none;
            -khtml-user-select: none;
            user-select: none;
            background: #fff;
            vertical-align: top;
            line-height: 40px;
            font-size: 15px;
            text-decoration: none;
            margin: 0 2px;
            border-radius: 6px;
        }

        .pager span.current {
            background-color: #222a35;
            color: #fff;
            border-color: #ebebeb;
        }

        .pager .pg-first,
        .pager .pg-prev,
        .pager .pg-next,
        .pager .pg-last {
            background: #fff url(https://img.alicdn.com/tfs/TB1kugrx4D1gK0jSZFKXXcJrVXa-58-56.jpg) 8px 7px no-repeat;
        }

        .pager .pg-prev,
        .pager .pg-prev:hover {
            background-position: 7px -21px;
        }

        .pager .pg-next,
        .pager .pg-next:hover {
            background-position: -21px -21px;
        }

        .pager .pg-last,
        .pager .pg-last:hover {
            background-position: -21px 7px;
        }

        .bottoms {
            width: 196px;
            margin: 200px auto 20px;
            background-color: #ddd;
        }

        .pager {
            display: flex;
            margin-bottom: 0;
            position: relative;
            left: 0;
            margin-left: 0;
            overflow-x: scroll;
            transition: all 0.5s linear;
            -ms-scroll-chaining: chained;
            -ms-content-zooming: zoom;
            -ms-scroll-rails: none;
            -ms-content-zoom-limit-min: 100%;
            -ms-content-zoom-limit-max: 500%;
            -ms-scroll-snap-type: proximity;
            -ms-scroll-snap-points-x: snapList(100%,200%,300%,400%,500%);
            -ms-overflow-style: none;
        }
        .pager::-webkit-scrollbar {
            display: none;
        }
        .page {
            width: 245px;
            margin: 0 auto;
        }
        .page button {
            width: 40px;
            margin-left: 10px;
        }
    </style>
</head>

<body style="">
    <div class="newsl"></div>
    <div class="bottoms">
        <div class="pager">
            <span data-id="1" class="">1</span>
            <span data-id="2" class="">2</span>
            <span data-id="3" class="">3</span>
            <span data-id="4" class="">4</span>
            <span data-id="5" class="">5</span>
            <span data-id="6">6</span>
            <span data-id="7" class="current">7</span>
            <span data-id="8">8</span>
            <span data-id="9">9</span>
            <span data-id="10">10</span>
        </div>
    </div>

    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script>
        class move {
            constructor(num) {
                this.client = num || 3; //一行显示个数
                this.total = 0; //总数
                this.minClientW = 0; //左侧非移动区域
                this.maxClientW = 0; //右侧非移动区域
                this.init();
                this.bindEvent();
            }

            init() {
                this.total = $(".bottoms .pager span").length;
                this.minClientW = Math.floor(this.client / 2); 
                this.maxClientW = this.total - Math.ceil(this.client / 2);
                $(".bottoms .pager span").eq(0).addClass('current');
                $('.bottoms').css('width', this.client * 49 + 'px')
            }

            bindEvent() {
                const { minClientW, maxClientW, client } = this;

                $(".bottoms .pager span").on("click", function () {
                    let that = $(this);
                    add(that, that.index(), client);
                })

                function add(that, cindex = 0, client = 3) {
                    let wi = 0;
                    // if (cindex < minClientW) { //当处在左侧非移动
                    //     wi = 0;
                    // } 
                    if ((cindex >= minClientW) && (cindex < maxClientW)) {
                        wi = (cindex - minClientW) * 49;
                    } else if (cindex >= maxClientW) {  //当处在右侧非移动
                        wi = (maxClientW - minClientW) * 49;
                    }
                    that.parent().animate({'scrollLeft': wi},100);
                    that.addClass('current').siblings().removeClass('current');
                }
            }
        }
        new move(5)

    </script>
  </body>
</html>